using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using DeviceSolutions.SPOT.Hardware;

namespace Alarm
{
    public class Alarm_SPI
    {
        private SPI AlarmSTK;


        //Initialize the configuration of SPI buses to communicate with the STK500
        public Alarm_SPI()
        {
            SPI.Configuration config =
                new SPI.Configuration(Meridian.Pins.SPI_SS,
                    false, 0, 0, true, true, 300, SPI.SPI_module.SPI1);

            AlarmSTK = new SPI(config);
            AlarmSTK.Config = config;
            Debug.Print("Config ok");
        }

        //Method to send data to STK500
        public void SetAlarm_SPI()
        {
            //Create new array of byte
            byte[] tx_data = new byte[8];
            byte[] rx_data = new byte[8];

            //Fill the array to send with all bit at one
            for (int i = 0; i < 8; i++)
            {
                tx_data[i] = 1;
            }
            //Send data to the device
            AlarmSTK.WriteRead(tx_data, rx_data);
            Debug.Print("Message send");
        }

        
    }
}
